var e = require("../../../@babel/runtime/helpers/interopRequireDefault"), t = e(require("../../../@babel/runtime/regenerator")), n = require("../../../@babel/runtime/helpers/asyncToGenerator"), r = e(require("../../../utils/logs")), i = getApp();

Page({
    data: {
        integral: "",
        placementId: "",
        mini_form_id: "",
        level_credit: 0,
        level_data: [],
        adv_list: [],
        member: {},
        level_index: 0,
        redirectToUrl: "",
        Partner: !1,
        pid: "",
        isclick: !1
    },
    onLoad: function(e) {
        var t = wx.getStorageSync("integral");
        t && this.setData({
            integral: t
        }), e.wxad && this.setData({
            mini_form_id: e.wxad
        }), this.data.redirectToUrl = "/packageI/AdBright/AdBrightIndex/AdBrightIndex", 
        this.init();
    },
    init: function() {
        var e = this;
        return n(t.default.mark(function n() {
            var i, o;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    i = e, o = null, wx.createRewardedVideoAd && ((o = wx.createRewardedVideoAd({
                        adUnitId: e.data.mini_form_id
                    })).onLoad(function() {
                        o.show(), console.log("onLoad event emit");
                    }), o.onError(function(e) {
                        console.log("onError event emit", e);
                    }), o.onClose(function(t) {
                        return o.destroy(), t.isEnded ? (console.log("流量主广告达到奖励条件", t), r.default.info("------------流量主广告达到奖励条件--------------", t), 
                        void i.getReward(!0)) : void wx.reLaunch({
                            url: e.data.redirectToUrl
                        });
                    }));

                  case 3:
                  case "end":
                    return t.stop();
                }
            }, n);
        }))();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getReward: function(e) {
        var t = this;
        if (!this.data.isclick) {
            this.data.isclick = !0;
            var n = this, r = i.getNetAddresss("plugin.flyers-advertise.frontend.reward.miniReward");
            i._postNetWork({
                url: r,
                success: function(r) {
                    var i = r.data;
                    wx.showModal({
                        title: "提示",
                        content: i.msg,
                        showCancel: !1,
                        success: function(r) {
                            e && wx.reLaunch({
                                url: n.data.redirectToUrl,
                                success: function(e) {
                                    t.data.isclick = !1;
                                }
                            });
                        }
                    });
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        }
    }
});